package com.example.bizconsumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/test")
public class ConsumerController {
    @Autowired
    RestTemplate restTemplate;

    @GetMapping
    public String test1(){
        return "test1--end";
    }

    @GetMapping("/hello-consumer")
    public String helloConsumer() {
        // 通过服务名调用服务提供者的接口
        return restTemplate.getForEntity("http://biz-provider/provider/hello", String.class)
                .getBody();
    }
}
